import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/extend_entity.dart';

ExtendEntity $ExtendEntityFromJson(Map<String, dynamic> json) {
  final ExtendEntity extendEntity = ExtendEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    extendEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    extendEntity.msg = msg;
  }
  final List<ExtendData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ExtendData>(e) as ExtendData).toList();
  if (data != null) {
    extendEntity.data = data;
  }
  return extendEntity;
}

Map<String, dynamic> $ExtendEntityToJson(ExtendEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension ExtendEntityExtension on ExtendEntity {
  ExtendEntity copyWith({
    int? code,
    String? msg,
    List<ExtendData>? data,
  }) {
    return ExtendEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

ExtendData $ExtendDataFromJson(Map<String, dynamic> json) {
  final ExtendData extendData = ExtendData();
  final String? controlType = jsonConvert.convert<String>(json['control_type']);
  if (controlType != null) {
    extendData.controlType = controlType;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    extendData.name = name;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    extendData.title = title;
  }
  final String? itemOption = jsonConvert.convert<String>(json['item_option']);
  if (itemOption != null) {
    extendData.itemOption = itemOption;
  }
  final List<Map>? datas = (json['datas'] as List<dynamic>?)?.map(
          (e) =>
          (e as Map<String, dynamic>).map(
                  (k, e) => MapEntry(k, e))).toList();
  if (datas != null) {
    extendData.datas = datas;
  }
  return extendData;
}

Map<String, dynamic> $ExtendDataToJson(ExtendData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['control_type'] = entity.controlType;
  data['name'] = entity.name;
  data['title'] = entity.title;
  data['item_option'] = entity.itemOption;
  return data;
}

extension ExtendDataExtension on ExtendData {
  ExtendData copyWith({
    String? controlType,
    String? name,
    String? title,
    String? itemOption,
    List<Map>? datas,
  }) {
    return ExtendData()
      ..controlType = controlType ?? this.controlType
      ..name = name ?? this.name
      ..title = title ?? this.title
      ..itemOption = itemOption ?? this.itemOption
      ..datas = datas ?? this.datas;
  }
}